package pl.edu.pk.mech.kkbus.controller;

import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pl.edu.pk.mech.kkbus.model.ExchangePoints;
import pl.edu.pk.mech.kkbus.model.ResponseStatus;
import pl.edu.pk.mech.kkbus.service.ExchangePointsService;

@Controller
public class ExchangeController extends RestController {

    private static final Logger log = Logger.getLogger(ExchangeController.class.getName());
    
    @Autowired
    ExchangePointsService exchangeService;
    
    @RequestMapping(value = "/exchange", method = RequestMethod.POST)
    public @ResponseBody ResponseStatus createUser(@RequestBody ExchangePoints exchange) {  
        // TODO Validation
        boolean result = exchangeService.createOrExchange(exchange);
        
        return result ? ResponseStatus.ADDED : ResponseStatus.ERROR;
    } 
}
